/**
 * @Author Puzzle
 * @Date 2022/6/13 2:15 下午
 **/

package system_layer

import (
	"zsc-boot/app/system_layer/model"
	"zsc-boot/app/system_layer/router"
	"zsc-boot/app/system_layer/service"
	"zsc-boot/core"
	"zsc-boot/core/orm"
	"zsc-boot/core/web"
)

func Init() {
	web.GetGin().Use(service.JWTMiddleware)
	router.InitBasePublicRouterGroup()
	router.InitServiceDepartmentRouterGroup()
	router.InitServiceMenuRouterGroup()
	router.InitServiceRoleRouterGroup()
	router.InitServiceUsersRouterGroup()
	router.InitServiceDocumentRouterGroup()
	router.InitDictionaryRouterGroup()

	orm.AutoMigrate(
		&model.ServiceDepartment{},
		&model.ServiceMenu{},
		&model.ServiceRole{},
		&model.ServiceUser{},
		&model.ServiceRoleMenu{},
		&model.LogLogin{},
		&model.ServiceDocument{},
		&model.Dictionary{},
		&model.ServiceCity{},
	)

	//清空每日配额
	core.RegCron("1 0 * * *", func() {
		orm.GetDb().Model(&model.ServiceUser{}).Update("today_len", 0)
	})
}
